package website.caidabao.blog.thymeleaf.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import website.caidabao.blog.thymeleaf.mapper.ArticleMapper;
import website.caidabao.blog.thymeleaf.pojo.Article;

import java.util.HashMap;
import java.util.Map;
@Service
public class ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    /**
     * 提供read.html的thymeleaf Map数据
     * @param id
     * @return
     */
    public Map<String, Object> loadModel(Long id) {
        Map<String,Object> map=new HashMap<>();
        Article keyArticle=new Article();
        keyArticle.setId((int)((long)id));
        Article article = this.articleMapper.selectByPrimaryKey(keyArticle);
        map.put("articleTitle",article.getArticleTitle());
        map.put("articleContent",article.getArticleContent());
        map.put("createTime",article.getCreateTime());
        map.put("articleId",article.getId());
        return map;

    }
}
